package com.schoolgard.entitybean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "ROLE_PRIVILEGE")
@SequenceGenerator (name="AUTO_ID", sequenceName="AUTO_ID")
public class RolePrivilege implements java.io.Serializable {

	private static final long serialVersionUID = 201202251306L;
	// Fields

	private Long id;
	private Role role;
	private String enable;
	private Long privilegeDevice;
	private String privilegeMenu; //菜单ID

	// Constructors

	/** default constructor */
	public RolePrivilege() {
	}

	/** minimal constructor */
	public RolePrivilege(Long id, Role role) {
		this.id = id;
		this.role = role;
	}

	/** full constructor */
	public RolePrivilege(Long id, Role role, String enable,
			Long privilegeDevice, String privilegeMenu) {
		this.id = id;
		this.role = role;
		this.enable = enable;
		this.privilegeDevice = privilegeDevice;
		this.privilegeMenu = privilegeMenu;
	}

	// Property accessors
	@Id
	@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
	@GeneratedValue (strategy=GenerationType.SEQUENCE, generator="AUTO_ID")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ROLE_ID", nullable = false)
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Column(name = "ENABLE", length = 1)
	public String getEnable() {
		return this.enable;
	}

	public void setEnable(String enable) {
		this.enable = enable;
	}

	@Column(name = "PRIVILEGE_DEVICE", precision = 10, scale = 0)
	public Long getPrivilegeDevice() {
		return this.privilegeDevice;
	}

	public void setPrivilegeDevice(Long privilegeDevice) {
		this.privilegeDevice = privilegeDevice;
	}

	@Column(name = "PRIVILEGE_MENU", length=1000)
	public String getPrivilegeMenu() {
		return this.privilegeMenu;
	}

	public void setPrivilegeMenu(String privilegeMenu) {
		this.privilegeMenu = privilegeMenu;
	}

}